<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>餐具费用设置</title>
    <script src="js/vue221.js" th:src="@{/js/vue.js}"></script>
    <script src="js/vue-router231.js" th:src="@{/js/vue-router.js}"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="css/element.css" th:href="@{/css/element.css}">
    <link rel="stylesheet" href="css/global.css" th:href="@{/css/global.css}"/>
    <link rel="stylesheet" href="css/main.css" th:href="@{/css/main.css}"/>
    <link rel="stylesheet" href="css/myelement.css" th:href="@{/css/myelement.css}"/>
    <!-- 引入组件库 -->
    <script src="js/element.js" th:src="@{/js/element.js}"></script>
</head>
<body>
<div id="app">
    <div class="main-content">
        <!-- 页面头部 -->
        <div class="page-header">
            <h1 class="page-title">餐具费用设置</h1>
            <div class="breadcrumb"><a href="javascript: top.location.reload();">首页</a><span>/</span>设置</div>
        </div><!-- 页面头部 end -->

        <div class="main-content-body">
            <div class="view-order mb_20">
                <div class="view-item">
                    设置餐具费用
                </div>
            </div>
            <div class="edit-form">
                <el-form :model="vendorBasic" :rules="rules" ref="dataForm" label-width="100px" class="demo-ruleForm">
                    <h3 class="edit-form-title">餐具费用</h3>
                    <el-form-item label="餐具费用" prop="coverPrice">
                        <el-input v-model.number="vendorBasic.coverPrice" style="width: 80px" placeholder="请输入金额"></el-input>元/人
                    </el-form-item>

                    <div class="edit-button-fixed">
                        <div class="edit-button z-yuan-butn">
                            <el-button type="primary" @click="submitForm('dataForm')">确定</el-button>
                            <el-button @click="handelCancel()">取消</el-button>
                        </div>
                    </div>
                </el-form>

            </div>
        </div>
    </div>
</div>



</body>
<script src="js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script th:inline="javascript">
    new Vue({
        el: "#app",
        data: {
            // form 表单数据
            vendorBasic: [[${vendorBasic}]],
            // form 表单验证规则
            rules: {
                coverPrice: [
                    { required: true, message: '请输入金额', trigger: 'blur' },
                    { type: 'number', message: '餐具费用必须为数字值'}
                ]
            }
        },
        computed: {

        },
        methods: {
            // 提交表单
            submitForm(formName) {
                let self = this;
                self.$refs[formName].validate((valid) => {
                    if (valid) {
                        self.loading = true;
                        $.ajax({
                            url: "/vendor/vendorbasic/setCover",
                            type: "POST",
                            data: JSON.stringify(self.vendorBasic),
                            contentType: "application/json;charset=UTF-8",
                            dataType: "json",
                            success: function (data) {
                                if (data && data.returnCode == "1") {
                                    self.$message({
                                        showClose: true,
                                        duration: 1500,
                                        message: '设置餐具费用成功',
                                        type: 'success',
                                        customClass: 'message-center'
                                    });
                                } else {
                                    self.$message({
                                        showClose: true,
                                        duration: 1500,
                                        message: '设置餐具费用失败',
                                        type: 'error',
                                        customClass: 'message-center'
                                    });
                                    self.loading = false;
                                }
                            },
                            error: function () {
                                self.$message({
                                    showClose: true,
                                    duration: 1500,
                                    message: '系统异常，请联系管理员.',
                                    type: 'error',
                                    customClass: 'message-center'
                                });
                                self.loading = false;
                            }
                        });
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            // 取消
            handelCancel() {
                history.back(-1);
            }
        }
    });
</script>
</html>
